﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using MiscUtil.IO;

namespace TlvLib.SiChuan
{
    class TlvReader
    {
        private static NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
        public static byte[] Read(Stream stream)
        {
            //_logger.Info("========开始接受数据数据=========="); 
            var tagBuffer = StreamUtil.ReadExactly(stream, 4);
            var lenBuffer = StreamUtil.ReadExactly(stream, 4);
            var len = Configuration.EndianBitConverter.ToInt32(lenBuffer, 0);
            //_logger.Info("数据包长为{0}", len); 
            var valueBuffer = StreamUtil.ReadExactly(stream, len);
           // _logger.Info("********接受数据包长为{0}完毕******", len); 
            return valueBuffer;
        }
    }
}
